package com.aluvfy.jdbc;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author: aluvfy
 * @description: 使用HikariCP连接池技术
 * @date: 2024/10/22 22:28
 */
public class JDBCTest26 {
    public static void main(String[] args) throws Exception{
        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("jdbc2.properties");
        //创建属性类对象
        Properties properties = new Properties();
        properties.load(in);
        //创建配置信息对象
        HikariConfig config = new HikariConfig(properties);
        //获取连接池
        DataSource dataSource = new HikariDataSource(config);

        Connection conn = dataSource.getConnection();
        System.out.println(conn);

        //....CRUD

        conn.close();
    }
}
